/**
 * 
 */
package com.hien.starting;

import com.hien.adapter.GridViewAdapter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

public class HomeActivity extends Activity implements OnItemClickListener {

	private String[] iconsName = { "Go Fishing, Tips/Hints, Get Fun, About Us" };
	private int[] imgResources = { R.drawable.home_fishing_selector,
			R.drawable.home_tips_selector, R.drawable.home_info_selector,
			R.drawable.home_about_selector };
	protected static final String STATE = "STATE";
	protected static final int INFO = 3;
	protected static final int DONKEY = 2;
	protected static final int TIPS = 1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.home_layout);

		iconsName = getResources().getStringArray(R.array.icons_name);
		GridView gridView = (GridView) findViewById(R.id.gridView_home);

		gridView.setAdapter(new GridViewAdapter(this, iconsName, imgResources));
		gridView.setOnItemClickListener(this);
	}

	@Override
	public void onItemClick(AdapterView<?> adapter, View view, int position,
			long id) {
		Intent i = null;
		switch (imgResources[position]) {
		case R.drawable.home_fishing_selector:
			i = new Intent(HomeActivity.this, FoolTabActivity.class);
			break;
		case R.drawable.home_tips_selector:
			i = new Intent(HomeActivity.this,FoolTabActivity.class);
			i.putExtra(STATE, TIPS);
			break;
		case R.drawable.home_info_selector:
			i = new Intent(HomeActivity.this, FoolTabActivity.class);
			i.putExtra(STATE,INFO );
			break;
		}
		if (i != null)
			startActivity(i);
	}

}
